﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GPSTypes.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.GPSTypes" %>

<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Tipos de dispositivos</title>
    <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
        <script type="text/javascript">
            function resizeGrid() {
                var tableView = $find("<%=GPSTypeGrid.ClientID %>");
            tableView.get_element().style.height = (window.innerHeight) + "px";
            document.getElementById('HiddenFieldHeight').value = (window.innerHeight);
        }

        var uploadedFilesCount = 0;
        var isEditMode;
        function validateRadUpload(source, e) {
            // When the RadGrid is in Edit mode the user is not obliged to upload file.
            if (isEditMode == null || isEditMode == undefined) {
                e.IsValid = false;

                if (uploadedFilesCount > 0) {
                    e.IsValid = true;
                }
            }
            isEditMode = null;
        }

        function OnClientFileUploaded(sender, eventArgs) {
            uploadedFilesCount++;
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();
        </script>
    </telerik:RadScriptBlock>
</head>
<body onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="GPSTypeGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="GPSTypeGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="500" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" />
        <div>
            <telerik:RadGrid ID="GPSTypeGrid" runat="server" AutoGenerateColumns="False" AllowSorting="true" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnNeedDataSource="GPSTypeGrid_NeedDataSource" OnInsertCommand="GPSTypeGrid_InsertCommand" OnDeleteCommand="GPSTypeGrid_DeleteCommand" OnUpdateCommand="GPSTypeGrid_UpdateCommand">
                <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;">
                            Menu: 
                             <asp:LinkButton ID="lbAdd" runat="server" CommandName="InitInsert" Visible='<%# !GPSTypeGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/text-plus-icon.png"/>Nuevo Tipo</asp:LinkButton>
                            <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFilters_Click" Visible='<%# !GPSTypeGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>
                            <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error técnivo</asp:LinkButton>
                        </div>
                    </CommandItemTemplate>
                    <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Nuevo Tipo" RefreshText="Actualizar"></CommandItemSettings>

                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>

                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>

                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" EditText="Editar" HeaderStyle-Width="30px" />
                        <telerik:GridButtonColumn ConfirmText="¿Desea eliminar el registro?" Text="Eliminar" ConfirmDialogType="RadWindow" ConfirmDialogHeight="120" ConfirmDialogWidth="270" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" HeaderStyle-Width="30px" />
                        <telerik:GridBoundColumn DataField="GpsTypeId" FilterControlAltText="Filter GPSTypeID column" HeaderText="GPSTypeID" UniqueName="GpsTypeId" ReadOnly="true" ForceExtractValue="Always" Display="false" HeaderStyle-Width="25px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Tipo" MaxLength="50" UniqueName="Name"
                            FilterControlWidth="185px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="215px" AutoPostBackOnFilter="true">
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn HeaderText="Imagen" UniqueName="Image" DataField="Image" ForceExtractValue="Always" AllowFiltering="false">
                            <ItemTemplate>
                                <asp:Image ID="ImageOriginal" ImageUrl='<%# "../../Template/Icons/GPSType/"+Eval("Image") %>' runat="server" AlternateText='<%# Eval("Image") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadAsyncUpload ID="RadUpload1" ToolTip='<%# Eval("Image") %>' InitialFileInputsCount="1" Localization-Select="Buscar" OverwriteExistingFiles="true" ControlObjectsVisibility="None" runat="server"
                                    OnClientFileUploaded="OnClientFileUploaded" AllowedFileExtensions="jpg,png">
                                </telerik:RadAsyncUpload>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>

                    <EditFormSettings>
                        <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <ClientSettings EnableRowHoverStyle="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                    <Selecting AllowRowSelect="True"></Selecting>
                    <ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
        </div>
    </form>
</body>
</html>
